local switchBtn = 4
local clickNum = 1 -- 控制台打印用

OutputLogMessage("分隔------------------------------------------------------分隔\n")
EnablePrimaryMouseButtonEvents(true)

local function jianKe(isRepeating)
    while true do
        OutputLogMessage("触发: %s\n", clickNum)
        clickNum = clickNum + 1

        PressKey('f')
        Sleep(math.random(38, 88))
        ReleaseKey('f')

        Sleep(math.random(5, 38))

        PressKey(57)
        Sleep(math.random(38, 88))
        ReleaseKey(57)

        Sleep(math.random(5, 38))

        PressKey('f')
        Sleep(math.random(38, 88))
        ReleaseKey('f')

        if isRepeating then
            Sleep(math.random(1050, 1150))
        end

        if not isRepeating or not IsKeyLockOn("capslock") then
            break
        end
    end
end

function OnEvent(event, arg)
    -- OutputLogMessage("Event: " .. event .. " Arg: " .. arg .. "\n")
    -- OutputLogMessage("date: " .. GetRunningTime() .. "\n")

    if event == "MOUSE_BUTTON_PRESSED" and arg == switchBtn then
        -- 剑客闪
        local isCapsLockOn = IsKeyLockOn("capslock")
        jianKe(isCapsLockOn)
    end

    if event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
        -- 虚空卡重刀
        -- while IsKeyLockOn("capslock") do
        --     -- (鼠标)右键单击
        --     PressMouseButton(2)
        --     Sleep(math.random(50, 150))
        --     ReleaseMouseButton(2)
        --     -- 间隔
        --     Sleep(math.random(500, 1000))
        --     -- (键盘)按下“F”键
        --     PressKey('f')
        --     Sleep(math.random(38, 150))
        --     ReleaseKey('f')
        --     --取消F循环
        -- end
    end
end
